package com.changan.mapper;

import com.changan.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //@Select("select * from user")
    List<User> getUsers();

    @Select("select * from user where id = #{id} ")
    User getUserById(Long id);

    @Insert("INSERT INTO `mybatis`.`user`(`id`, `name`, `age`, `email`) VALUES (null, #{name} , #{age}, #{email} )")
    int addUser(User user);

    @Update("UPDATE `mybatis`.`user` SET `name` = #{name}, `age` = #{age}, `email` = #{email}  WHERE `id` = #{id}")
    int updateUser(User user);

    @Delete("delete from user where id = #{id}")
    int deleteUser(Long id);
}
